cmake_minimum_required(VERSION 3.15)
project(Kaleidoscope)

set(CMAKE_CXX_STANDARD 14)
if(NOT DEFINED ENV{LLVM_DIR})
    set(ENV{LLVM_DIR} /Users/wen/Documents/llvm_learn/llvm-project/build/lib/cmake/llvm)
endif()

find_package(LLVM REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# Set your project compile flags.
# E.g. if using the C++ header files
# you will need to enable C++11 support
# for your compiler.
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

# Now build our tools
add_executable(toy toy.cc)
# Find the libraries that correspond to the LLVM components
# that we wish to use
# 需要连接的components
llvm_map_components_to_libnames(llvm_libs core orcjit native)
# Link against LLVM libraries
target_link_libraries(toy ${llvm_libs})
message(STATUS "FIND ${llvm_libs}")